package com.dqyt.app.controller;

import com.alibaba.fastjson.JSON;
import com.dqyt.app.service.ReportService;
import com.dqyt.khjc.bean.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 报告控制器
 */
@RestController
public class ReportController {

    /**
     * 报告操作类
     */
    @Autowired
    private ReportService mReportService;

    @RequestMapping("/report/testReport")
    public String testReport() {
        return JSON.toJSONString(mReportService.testReport());
    }

    /**
     *  分页查询报告
     * @param request
     * @param userId  用户id
     * @param token
     * @param addTime
     * @param reportStatue  报告状态
     * @param erweima  二维码
     * @param deviceType  设备类型
     * @param reportProgress  报告进度
     * @return
     */
    @RequestMapping("/sample/getReportInfos")
    public String getReportInfos(HttpServletRequest request,int page,int size, long userId,
                                 String token, long addTime,int deviceType, int reportStatue,int reportProgress , String bsbh, String erweima,long wtfId) {
        return JSON.toJSONString(mReportService.getReportInfos(request,page,size, userId, token, addTime, reportStatue, bsbh, erweima,deviceType,reportProgress,wtfId));
    }

    /**
     * 新增报告信息
     *
     * @param request
     * @param userId
     * @param token
     * @param Report
     * @return
     */
    @RequestMapping("/report/addReport")
    public String addReport(HttpServletRequest request, long userId, String token, String Report) {
        return JSON.toJSONString(mReportService.addReport(request, userId, token, Report));
    }

    /**
     * 更新报告信息
     *
     * @param request
     * @param userId
     * @param token
     * @param Report
     * @return
     */
    @RequestMapping("/report/updateReport")
    public String updateReport(HttpServletRequest request, long userId, String token, String Report) {
        return JSON.toJSONString(mReportService.updateReport(request, userId, token, Report));
    }


    /**
     * 驳回报告
     * @param request
     * @return
     */
    @RequestMapping(value = "/sample/rejectReportDal", method = {RequestMethod.POST})
    public ResultMsg refuseDal(HttpServletRequest request, long userId, String token, String bh, int reportProgress, String bhgyy){
        ResultMsg resultMsg = mReportService.rejectReportDal(request,userId,token,bh, reportProgress,bhgyy);
        return resultMsg;
    }


    /**
     * 报告通过审核
     * @param request
     * @return
     */
    @RequestMapping(value = "/sample/reportAdoptExamine", method = {RequestMethod.POST})
    public ResultMsg  reportAdoptExamine(HttpServletRequest request,long userId, String token,String bh){
        ResultMsg resultMsg = mReportService.reportAdoptExamine(request,userId,token,bh);
        return resultMsg;
    }



    /**
     * 报告通过批准
     * @param request
     * @return
     */
    @RequestMapping(value = "/sample/reportAdoptApproval", method = {RequestMethod.POST})
    public ResultMsg  reportAdoptApproval(HttpServletRequest request,long userId, String token,String bh){
        ResultMsg resultMsg = mReportService.reportAdoptApproval(request,userId,token,bh);
        return resultMsg;
    }


}
